import Page
from Page import Carpark
from Base.Base import Base
from selenium.webdriver.common.by import By


class CarparkIdiomsGamePage(Base):
    """
    车乐汇成语接龙游戏页

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 关闭按钮
        self.game_close_btn = (By.XPATH, Carpark.RESOURCE_ID_Idioms.format("iv_close"))

        # 成语接龙律动
        self.game_rhythm_icon = (By.XPATH, Carpark.RESOURCE_ID_Idioms.format("view_asv"))

        # 成语接龙提示
        self.game_tip_text = (By.XPATH, Carpark.RESOURCE_ID_Idioms.format("tv_tts"))

        # 成语接龙内容
        self.game_connect_text = (By.XPATH, Carpark.RESOURCE_ID_Idioms.format("tv_tips"))

        # 成语接龙成语答案
        self.game_idioms_answer_text = (By.XPATH, Carpark.RESOURCE_ID_Idioms.format("tv_answer"))

    def click_close(self):
        """
         点击关闭按钮

         :return:None
         """
        self.click_element(self.game_close_btn)

    def get_rhythm_(self):
        """
        获取成语接龙标题

        :return:获取元素
        """
        return self.find_element_o(self.game_rhythm_icon)

    def get_tip(self):
        """
        获取成语接龙提示

        :return:获取元素
        """
        return self.find_element_o(self.game_tip_text)

    def get_connect(self):
        """
        获取成语接龙内容

        :return:获取元素
        """
        return self.find_element_o(self.game_connect_text)

    def get_idioms_answer(self):
        """
        获取成语接龙答案

        :return:获取元素
        """
        return self.find_element_o(self.game_idioms_answer_text)

    def is_display_carpark_game(self):
        """
        查看是否进入车乐汇成语接龙游戏页

        :return:
        """
        return self.is_display(self.game_connect_text)
